home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / Library / Utils / MoreMath.as < prev    next >
Text File  |  2007-09-27  |  2KB  |  88 lines

  1. class Library.Utils.MoreMath
  2. {
  3.    function MoreMath()
  4.    {
  5.    }
  6.    static function getRandomRange(__nMin, __nMax)
  7.    {
  8.       return Math.floor(Math.random() * (__nMax + 1 - __nMin)) + __nMin;
  9.    }
  10.    static function getPolarity(__nNum)
  11.    {
  12.       var _loc1_ = 0;
  13.       if(__nNum < 0)
  14.       {
  15.          _loc1_ = -1;
  16.       }
  17.       else if(__nNum > 0)
  18.       {
  19.          _loc1_ = 1;
  20.       }
  21.       return _loc1_;
  22.    }
  23.    static function getReachZero(__nNum, __nReducer)
  24.    {
  25.       return Library.Utils.MoreMath.getReachNum(__nNum,0,__nReducer);
  26.    }
  27.    static function getReachNum(__nNum, __nTargetNum, __nReducer)
  28.    {
  29.       var _loc1_ = __nNum;
  30.       if(_loc1_ != __nTargetNum)
  31.       {
  32.          if(_loc1_ < __nTargetNum)
  33.          {
  34.             _loc1_ += __nReducer;
  35.             if(_loc1_ > __nTargetNum)
  36.             {
  37.                _loc1_ = __nTargetNum;
  38.             }
  39.          }
  40.          else
  41.          {
  42.             _loc1_ -= __nReducer;
  43.             if(_loc1_ < __nTargetNum)
  44.             {
  45.                _loc1_ = __nTargetNum;
  46.             }
  47.          }
  48.       }
  49.       return _loc1_;
  50.    }
  51.    static function getDistance(__nX1, __nY1, __nX2, __nY2)
  52.    {
  53.       return Math.sqrt(Math.pow(Math.abs(__nX2 - __nX1),2) + Math.pow(Math.abs(__nY2 - __nY1),2));
  54.    }
  55.    static function getHypotenuse(__nDX, __nDY)
  56.    {
  57.       return Math.sqrt(Math.pow(__nDX,2) + Math.pow(__nDY,2));
  58.    }
  59.    static function getAngle(__nX1, __nY1, __nX2, __nY2)
  60.    {
  61.       var _loc2_ = undefined;
  62.       var _loc1_ = undefined;
  63.       var _loc4_ = undefined;
  64.       var _loc3_ = undefined;
  65.       _loc2_ = __nX2 - __nX1;
  66.       _loc1_ = __nY2 - __nY1;
  67.       _loc4_ = Math.atan2(_loc1_,_loc2_);
  68.       _loc3_ = Library.Utils.MoreMath.getDegreeFromRadius(_loc4_);
  69.       return _loc3_;
  70.    }
  71.    static function getDegreeFromRadius(__nRadius)
  72.    {
  73.       var _loc1_ = __nRadius / 3.141592653589793 * 180;
  74.       return _loc1_;
  75.    }
  76.    static function getRadianFromDegree(__nDegree)
  77.    {
  78.       var _loc1_ = __nDegree * 0.017453292519943295;
  79.       return _loc1_;
  80.    }
  81.    static function getBoundsCenter(_oBox)
  82.    {
  83.       var _loc3_ = (_oBox.xMin + _oBox.xMax) / 2;
  84.       var _loc2_ = (_oBox.yMin + _oBox.yMax) / 2;
  85.       return {x:_loc3_,y:_loc2_};
  86.    }
  87. }
  88.